import React from 'react'
import './index.less'

class Login extends React.Component {
	
	state = {
		username: '',
		password: '',
	}
	
	login = (e) => {
		e.preventDefault()
		console.log(this.state)
	}
	
	saveFormData = (type) => {
		return (event) => {
			this.setState({
				[type]: event.target.value
			})
		}
	}
	
	render() {
		// 读取状态
		// let { isHot } = this.state
		return (
			<form action="http://www.baidu.com" onSubmit={this.login}>
				用户名: <input onChange={this.saveFormData('username')} type="text" name="username" />
				密码: <input onChange={this.saveFormData('password')} type="password" name="password" />
				<button>登录</button>
			</form>
		)
	}
	
}

export default Login
